package com.group.three.controller.orderController;

import com.group.three.entity.myOrder.MemberEvaluationDTO;
import com.group.three.service.myorderservice.MemberEvaluationService;
import com.group.three.untils.SnowFlakeUtil;
import com.group.three.vo.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.math.BigInteger;
import java.util.Random;
import java.util.UUID;

/**
 * 买家端,会员商品评价接口
 *
 * @author Bulbasaur
 * @since 2020/11/16 10:08 下午
 */
@RestController
@Api(tags = "买家端,会员商品评价接口")
@RequestMapping("/buyer/member/evaluation")
public class MemberEvaluationBuyerController {
    @Autowired
    private MemberEvaluationService memberEvaluationService;

    @ApiOperation(value = "添加会员评价")
    @PostMapping
    public JsonResult save(@Valid MemberEvaluationDTO memberEvaluationDTO) {
        String s = String.valueOf(SnowFlakeUtil.getSnowFlakeId());
        String substring = s.substring(0, s.length() - 3);
        memberEvaluationDTO.setId(Long.parseLong(substring));
        int i = memberEvaluationService.addMemberEvaluation(memberEvaluationDTO);
        int j = memberEvaluationService.modifyOrderCommentStatus(memberEvaluationDTO.getOrderItemSn());
        if (i == 1 && j == 1) {
            return new JsonResult("200", "评价成功");
        }
        return new JsonResult("400", "评价失败");

    }
}
